package com.zxp01.selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;

import javax.swing.*;

public class Z03_Action {
    /*常用的鼠标操作*/
    WebDriver driver =new ChromeDriver();
    @Test
    public void action_op(){
        driver.manage().window().maximize();
        driver.get("https://www.baidu.com");
        /* 单机鼠标右键 */
        Actions RightClick = new Actions(driver);       //创建鼠标实例
        RightClick.contextClick(driver.findElement(By.xpath("//*[@id=\"s-top-left\"]/a[1]"))).perform();
        // 单机鼠标左键
//        driver.findElement(By.xpath("//*[@id=\"s-top-left\"]/a[1]")).click();
        // 双击
        RightClick.doubleClick(driver.findElement(By.id("s-usersetting-top"))).perform();

        // 鼠标移动到指定位置
       driver.navigate().to("http://www.treejs.cn/v3/demo/cn/exedit/drag.html");
       driver.navigate().refresh();
       RightClick.clickAndHold(driver.findElement(By.id("treeDemo_2_span"))).
               moveToElement(driver.findElement(By.id("treeDemo_3_span"))).release().build().perform();
    }
}